<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	request.setCharacterEncoding("UTF-8");	
	String htmlData = request.getParameter("content1") != null ? request.getParameter("content1") : ""; 
%>
<!DOCTYPE HTML>
<html>
  <head>
    <%@include file="../common.jsp"%>
    <title>引用职业考证资料</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">  
<!-- 	<link rel="stylesheet" type="text/css" href="resources/css/common.css">  -->
	<script type="text/javascript" src="resources/js/file/add_cert_file.js"></script>  
	<script type="text/javascript" src="resources/js/cookie.js"></script>

<script>
var cook = new cookie();//实例化cookie
/** ***********添加分类********************* */
	function addCategory(object) {
			// 一级分类选择
			var $second = object.find("[name=second]"), 
			$top = object.find("[name=top]");
			$detail = object.find("[name=detail]"), 
		    tcId = 	cook.getCookie("tcId");
			scId = 	cook.getCookie("scId");
			detailId =  cook.getCookie("detail");
			
			$.get("category/getTopCategoryOfCert",function(data) {
				$.each(data.data, function(i, obj) {
				 if(obj.tcId ==tcId){ 
						$top.append("<option value='" + obj.tcId + "' selected>" + obj.tcName+ "</option>");
					} else{
					$top.append("<option value='" + obj.tcId + "'>" + obj.tcName+ "</option>");
					}
				});
			}, "json");
			
			if(detailId.length !=0){
			//做缓存数据用开始
			$.ajax({ // 此处用同步处理，避免出现val()比reload早的问题
						url : serverURL + "category/getSecondaryCategory?"+ "tcId=" + tcId,
						type : "get",
						async : false,
						success : function(data) {
							if (data.code == 0) {
								var html = "";
								$.each(data.data, function(i, k) {
									if (k.scId == scId) {
										html += "<option value='" + k.scId+ "' selected>" + k.scName	+ "</option>";
									} else {
										html += "<option value='" + k.scId + "'>"+ k.scName + "</option>";
									}
								});
								$second.append(html);
							} else if (data.code != -1) {
								alert("一二级分类数据加载失败");
							}
						}
					});
					
			$.ajax({
				url : serverURL + "category/getDetailCategory?" + "scId=" + scId+ "&dcTypeId=0",
				type : "get",
				async : false,
				success : function(data) {
					if (data.code == 0) {
						var detail = content = projectMode = "";
						$.each(data.data, function(i, k) {
								if (k.dcId == detailId) {
									detail += "<option value='" + k.dcId+ "' selected >" + k.dcName+ "</option>";
								} else {
									detail += "<option value='" + k.dcId + "'>"+ k.dcName + "</option>";
								}
						});
						$detail.append(detail);
					} else if (data.code != -1) {
						alert("三级分类数据加载失败");
					}
				}
			});
			//做缓存数据结束
		}		
		
			/*--------------修改的一、二、三级二级联动处理----------------*/
			$top.change(function() {
				districtEdit.clearDetail();
				districtEdit.reloadSecond($(this).val());
			});
	
			$second.change(function() {
				districtEdit.reloadDetail($(this).val());
			});
	
			var districtEdit = {
				clearSecond : function() {
					$second.find("option[value!=0]").remove();
				},
				clearDetail : function() {
					$detail.find("option[value!=0]").remove();
				},
				reloadSecond : function(tcId) {
					districtEdit.clearSecond();
					if (tcId != 0) {
						$.ajax({ // 此处用同步处理，避免出现val()比reload早的问题
							url : serverURL + "category/getSecondaryCategory?"+ "tcId=" + tcId,
							type : "get",
							async : false,
							success : function(data) {
								if (data.code == 0) {
									var html = "";
									$.each(data.data, function(i, k) {
										html += "<option value='" + k.scId +"'>"+ k.scName + "</option>";
									});
									$second.append(html);
								} else if (data.code != -1) {
									alert("一二级分类数据加载失败");
								}
							}
						});
					}
				},
				reloadDetail : function(scId) {
					districtEdit.clearDetail();
					if (scId != 0) {
						$.ajax({
							url : serverURL + "category/getDetailCategory?"+ "scId=" + scId+"&dcTypeId=0",
							type : "get",
							async : false,
							success : function(data) {
								if (data.code == 0) {
									$.each(data.data, function(i, k) {
										$detail.append("<option value='" + k.dcId + "'>"+ k.dcName + "</option>");
									});
								} else if (data.code != -1) {
									alert("三级分类数据加载失败");
								}
							}
						});
					}
				}
			};
	}	
</script>
</head>
<body>
	<div class="content">
		<ol class="breadcrumb">
			<li><a href="cert.htm">职业考证体系资料</a></li>
			<li class="active">引用资料</li>
		</ol>
		<div class="modal-content">
			<div class="modal-body">
				<form id="form_add" class="form-horizontal" role="form">
					<input type="hidden" name="joinTable" value="cert">

					<div class="form-group">
						<label class="col-md-2 control-label required">一级分类</label>
						<div class='col-md-2'>
							<select class="form-control" name="top" placeholder="选择一级分类"
								data-toggle="tooltip" data-placement="top" title="请选择一级分类">
								<option value="0" selected="selected">请选择...</option>
							</select>
						</div>
						<label class="col-md-2 control-label required ">二级分类</label>
						<div class='col-md-2'>
							<select class="form-control" name="second" placeholder="选择二级分类"
								data-toggle="tooltip" data-placement="top" title="请选择二级分类">
								<option value="0" selected="selected">请选择...</option>
							</select>
						</div>
						<label class="col-md-2 control-label required">三级分类</label>
						<div class='col-md-2'>
							<select class="form-control" name="detail"  placeholder="选择三级分类" data-toggle="tooltip" data-placement="top"title="请选择三级分类">
								<option value="0" selected="selected">请选择三级分类...</option>
							</select>
						</div>
					</div>
					  
				  	  <div class="form-group">
						<label class="col-sm-2 control-label required" >规划体系</label>
						  <div class="col-sm-4">
							      	<select class="form-control" name="hierId" placeholder="选择规划体系"
										data-toggle="tooltip" data-placement="top" title="请选择规划体系">
										<option value="0" selected="selected">请选择规划体系...</option>
									</select>
						  </div>
						  
						  <label class="col-sm-2 control-label required">等级</label>
						  	<div class="col-sm-4">
							      	<select class="form-control" name="grade" placeholder="选择等级"
										data-toggle="tooltip" data-placement="top" title="请选择等级">
										<option value="1" selected="selected">入门</option>
										<option value="2" >进阶</option>
									</select>								
							</div>
					  </div>	
					  <div class="form-group">
						  	<div class="col-sm-10" style="float: right;">
								<button id="btn_myFile" type="button"  class="btn btn-primary"><i class="icon  icon-user"></i>  我的文件</button>
								<button id="btn_refresh" type="button"  class="btn btn-primary"><i class="icon  icon-spin icon-refresh"></i> 刷新</button>
							</div>
					  </div>
					  
				  	  <div class="form-group">
						<label class="col-sm-1 control-label required" >选择资料</label>
						  <div class="col-sm-11">
						  
					<div class="input-group">
						<div class="input-group-btn">
						<button id="btnGroupDrop1" type="button" class="btn dropdown-toggle" data-toggle="dropdown">请选筛选条件 <span class="caret"></span></button>
						    <ul class="dropdown-menu" role="menu" aria-labelledby="btnGroupDrop1">
						      <li><a href="javascript:void(0);"  id="0">下载次数</a></li>
						      <li><a href="javascript:void(0);" id = "1">评论次数</a></li>
						      <li><a href="javascript:void(0);" id ="2">收藏次数</a></li>
						    </ul>
						</div>
						<input type="number"   class="form-control"  style="width:50%;"id="num" placeholder="请输入…… ">
						<input type="text"   class="form-control"  style="width:50%;"id="fileName" placeholder="请输入标题…… ">
						<span class="input-group-addon" id ="search"><i class="icon icon-search" style="cursor:pointer;"></i></span>
					</div>
						  
 						<table  class="table table-bordered table-hover"  id = "same_dict_table">
					     		<thead>
						     		<th style="width:5%"><input id="pkall" type='checkbox' class='checkbox'></th>
						     		<th style="width:30%">标题</th>
						     		<th style="width:41%">简介</th>
						     		<th style="width:8%">下载次数</th>
						     		<th style="width:8%">评论次数</th>
						     		<th style="width:8%">收藏次数</th>
					     		</thead>
							  <tbody>
						       </tbody>
						     </table>
						     	  	<!-- 分页信息条 -->
								  	<div id="pagebar" class="pagebar">
									  	<ul class="pager">
									  		
										</ul>
										<p id="page_info" class="page_info">显示第<span>0</span>到第<span>0</span>条记录,共<span>0</span>条</p>
								  	</div> 
						  </div>
					  </div>	
				</form>
			</div>
			<div class="modal-footer">
				<button id="btn_confirm_add" type="button" class="btn btn-primary">确定</button>
			</div>
		</div>
	</div>
</body>
</html>